home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / hMailServer / hMailServer-4.1-Build-136.exe / {app} / Addons / Squirrelmail Plugins / hmailserver_changepass / functions.php next >
PHP Script  |  2004-07-06  |  5KB  |  149 lines

  1. <?php
  2.  
  3.  
  4. // include compatibility plugin
  5. //
  6. if (defined('SM_PATH'))
  7.    include_once(SM_PATH . 'plugins/compatibility/functions.php');
  8. else if (file_exists('../plugins/compatibility/functions.php'))
  9.    include_once('../plugins/compatibility/functions.php');
  10. else if (file_exists('./plugins/compatibility/functions.php'))
  11.    include_once('./plugins/compatibility/functions.php');
  12.  
  13.  
  14.  
  15. function hmailserver_changepass_check_password_force_do() {
  16.     
  17.    global $plugin_hmailserver_changepass;
  18.         
  19.                 
  20.    // get global variables for versions of PHP < 4.1
  21.    //   
  22.    if (!compatibility_check_php_version(4, 1)) {
  23.       global $HTTP_POST_VARS, $HTTP_SERVER_VARS;
  24.       $_POST = $HTTP_POST_VARS;
  25.       $_SERVER = $HTTP_SERVER_VARS;
  26.    }
  27.         
  28.                 
  29.    // get flag that tells us if this is a password submission attempt...
  30.    //   
  31.    if (isset($_POST['plugin_hmailserver_changepass']))
  32.       $plugin_hmailserver_changepass = $_POST['plugin_hmailserver_changepass'];
  33.  
  34.         
  35.    if (!isset($plugin_hmailserver_changepass))
  36.       return;     
  37.  
  38.         
  39.    // go check password
  40.    //
  41.    if (compatibility_check_SM_version(1, 3))
  42.       include_once(SM_PATH . 'plugins/hmailserver_changepass/options.php');
  43.    else
  44.       include_once('../plugins/hmailserver_changepass/options.php');
  45.  
  46.         
  47.    // if we come back after no success, redirect to right main
  48.    //   
  49.    $location = $_SERVER['PHP_SELF'];
  50.    $location = str_replace('webmail', 'right_main', $location); 
  51.    header('Location: ' . $location);
  52.    exit(0);
  53.                 
  54.                 
  55. }                       
  56.  
  57. function hmailserver_changepass_opt_do() {
  58.     global $optpage_blocks;
  59.         
  60.     $optpage_blocks[] = array(
  61.         'name' => _("Change Password"),
  62.         'url' => '../plugins/hmailserver_changepass/options.php',
  63.         'desc' => _("Use this to change your email password."),
  64.         'js' => FALSE
  65.     );          
  66.                 
  67. }       
  68.  
  69.         
  70. // OK, so this is not what this is supposed to be
  71. // used for(?), but I couldn't figure it out any
  72. // other way -- the save_pref method below is not
  73. // working anymore, especially after turning off
  74. // register_globals
  75. //      
  76. function hmailserver_changepass_optpage_loadinfo_do() {
  77.  
  78.    global $optpage_name, $plugin_hmailserver_changepass;
  79.  
  80.         
  81.    // get global variables for versions of PHP < 4.1
  82.    //   
  83.    if (!compatibility_check_php_version(4, 1)) {
  84.       global $HTTP_GET_VARS, $HTTP_POST_VARS;
  85.       $_GET = $HTTP_GET_VARS;
  86.       $_POST = $HTTP_POST_VARS;
  87.    }            
  88.                 
  89.                         
  90.    if (isset($_POST['plugin_hmailserver_changepass']))
  91.       $plugin_hmailserver_changepass = $_POST['plugin_hmailserver_changepass'];
  92.    if (isset($_GET['plugin_hmailserver_changepass']))
  93.       $plugin_hmailserver_changepass = $_GET['plugin_hmailserver_changepass'];
  94.  
  95.    
  96.    if (isset($plugin_hmailserver_changepass))
  97.       if ($plugin_hmailserver_changepass)
  98.          $optpage_name = _("Password changed successfully.<br>Please use your new password to log in from now on.");
  99.       else
  100.          $optpage_name = _("Password change cancelled.<br>Your password has NOT been changed.");
  101.         
  102. }       
  103.         
  104.         
  105.  
  106. // this is old school and doesn't work any more, especially
  107. // with register_globals = Off...
  108. //
  109. function hmailserver_changepass_save_pref_do() {
  110.  
  111.  
  112.    global $plugin_hmailserver_changepass, $optmode;
  113.  
  114.  
  115.    // get global variables for versions of PHP < 4.1
  116.    //
  117.    if (!compatibility_check_php_version(4, 1)) {
  118.       global $HTTP_GET_VARS, $HTTP_POST_VARS;
  119.       $_GET = $HTTP_GET_VARS;
  120.       $_POST = $HTTP_POST_VARS;
  121.    }
  122.    
  123.    
  124.    // get flag that tells us if this is a password submission attempt...
  125.    // 
  126.    if (isset($_GET['plugin_hmailserver_changepass']))
  127.       $plugin_hmailserver_changepass = $_GET['plugin_hmailserver_changepass'];
  128.    if (isset($_POST['plugin_hmailserver_changepass']))
  129.       $plugin_hmailserver_changepass = $_POST['plugin_hmailserver_changepass'];
  130.  
  131.    
  132.  
  133.    if (!isset($plugin_hmailserver_changepass))
  134.       return;
  135.  
  136.    $optmode = 'display';
  137.  
  138.    if (!$plugin_hmailserver_changepass)
  139.       echo '<p align=center><b>' . _("Password change cancelled.") . '  ' . _("Your password has NOT been changed.") . '</b></p>';
  140.  
  141.    else
  142.       echo '<p align=center><b>' . _("Password changed successfully.") . '  ' . _("Please use your new password to log in from now on.") . '</b></p>';
  143.  
  144. }
  145.  
  146.  
  147.  
  148. ?>
  149.